package test;

import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		Person[] persons = new Person[n];
		for (int i = 0; i < persons.length; i++) {
			String name = in.next();
			int age = in.nextInt();
			boolean gender = in.nextBoolean();
			persons[i] = new Person(name, gender, age);
		}
		for (int j = persons.length-1; j >= 0; j--) {
			System.out.println(persons[j]);
		}
		System.out.println(new Person());
	}
}
